package middle;

import java.util.Map;

public class Solution_299 {

    public static void main(String[] args) {
        Solution_299 model = new Solution_299();
        System.out.println(model.getHint("1807", "7810"));
        System.out.println(model.getHint("1123", "0111"));
    }

    public String getHint(String secret, String guess) {
        int count1 = 0, count2 = 0;
        int[] arrays1 = new int[10];
        int[] arrays2 = new int[10];
        for (int i = 0; i < secret.length(); i++) {
            char c1 = secret.charAt(i);
            char c2 = guess.charAt(i);
            if (c1 == c2) {
                count1++;
            } else {
                int num1 = c1 - '0';
                arrays1[num1]++;
                int num2 = c2 - '0';
                arrays2[num2]++;
            }
        }

        for (int i = 0; i < 10; i++) {
            count2 += Math.min(arrays1[i], arrays2[i]);
        }
        return count1 + "A"+ count2 + "B";
    }
}
